package com.vtest.quartz.task.report;

import com.vtest.quartz.domain.vtest.report.MCMWeekHoldEntity;
import com.vtest.quartz.domain.vtest.report.PRALYHDHoldWeekEntity;
import com.vtest.quartz.service.vtest.report.MCMService;
import com.vtest.quartz.utils.MailHelper;
import com.vtest.quartz.utils.excel.ExcelUtil;
import com.vtest.quartz.utils.others.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.List;

/**
 * @program: Quartz
 * @author: tiger
 * @create: 2025-02-06 08:44
 * @Description : MCM 客户的 报表任务
 */
@Slf4j
@Component("MCMReport")
public class MCMReport {

    @Autowired
    private MCMService mcmService;

    /*
     * MCM Week HOLD周报 每周一周四上午9：30
     */
    public void sendMCMWeekHoldReport() {
        log.debug("[MCM Week HOLD 周报表] 任务开始执行");
        List<MCMWeekHoldEntity> holdInfoList = mcmService.getHoldInfo();


        ExcelUtil<MCMWeekHoldEntity> util = new ExcelUtil<>(MCMWeekHoldEntity.class);
        util.exportExcel(holdInfoList, "MCM Hold", StringUtils.EMPTY, true);

        File localFile = new File(util.downFile);
        if (localFile.exists()) {
            MailHelper helper = new MailHelper();
            helper.sendMail("wuzhengjie@mindmotion.com.cn;mmpcgroup@mindmotion.com.cn;mm_ate@mindmotion.com.cn"
                    , "ruhu.wang@v-test.com.cn;ptesupport@v-test.com.cn;weilong.xu@v-test.com.cn" +
                            ";guoqing.yuan@v-test.com.cn;haolu.zhang@v-test.com.cn;xianggang.sun@v-test.com.cn" +
                            ";pte_db@v-test.com.cn"
                    , "MCM Week HOLD 报表"
                    , "MCM Week HOLD 报表", util.downFile);
        }
    }
}
